
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<HTML>

<HEAD>
   <TITLE>dvhat_c</TITLE>
</HEAD>

<BODY style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<A name="TOP"></A>

<table style="text-align: left; margin-left: auto; margin-right: auto; width: 800px;"
 border="0" cellpadding="5" cellspacing="2">
  <tbody>
    <tr>
      <td style="background-color: rgb(153, 153, 153); vertical-align: middle; text-align: center;">
      <div align="right"> 
      <small><small><a href="index.html">Index Page</a></small></small>
      </div>
      <b>dvhat_c</b> </td>
    </tr>

    <tr>
      <td style="vertical-align: top;">

<small><div align="center">
<A HREF="index.html#A">A</A>&nbsp;
<A HREF="index.html#B">B</A>&nbsp;
<A HREF="index.html#C">C</A>&nbsp;
<A HREF="index.html#D">D</A>&nbsp;
<A HREF="index.html#E">E</A>&nbsp;
<A HREF="index.html#F">F</A>&nbsp;
<A HREF="index.html#G">G</A>&nbsp;
<A HREF="index.html#H">H</A>&nbsp;
<A HREF="index.html#I">I</A>&nbsp;
<A HREF="index.html#J">J</A>&nbsp;
<A HREF="index.html#K">K</A>&nbsp;
<A HREF="index.html#L">L</A>&nbsp;
<A HREF="index.html#M">M</A>&nbsp;
<A HREF="index.html#N">N</A>&nbsp;
<A HREF="index.html#O">O</A>&nbsp;
<A HREF="index.html#P">P</A>&nbsp;
<A HREF="index.html#Q">Q</A>&nbsp;
<A HREF="index.html#R">R</A>&nbsp;
<A HREF="index.html#S">S</A>&nbsp;
<A HREF="index.html#T">T</A>&nbsp;
<A HREF="index.html#U">U</A>&nbsp;
<A HREF="index.html#V">V</A>&nbsp;
<A HREF="index.html#W">W</A>&nbsp;
<A HREF="index.html#X">X</A>&nbsp;
</div></small>
       <br>
       <table style="text-align: left; width: 60%; margin-left: auto; margin-right: auto;"
       border="0" cellspacing="2" cellpadding="2">
        <tbody>
          <tr>
            <td style="width: 50%; text-align: center;">
            <small>
              <a href="#Procedure">Procedure<br></a>
              <a href="#Abstract">Abstract<br></a>
              <a href="#Required_Reading">Required_Reading<br></a>
              <a href="#Keywords">Keywords<br></a>
              <a href="#Brief_I/O">Brief_I/O<br></a>
              <a href="#Detailed_Input">Detailed_Input<br></a>

              </small>
              </td>
              <td style="vertical-align: top; width: 50%; text-align: center;">
              <small>               <a href="#Detailed_Output">Detailed_Output<br></a>
              <a href="#Parameters">Parameters<br></a>
              <a href="#Exceptions">Exceptions<br></a>
              <a href="#Files">Files<br></a>
              <a href="#Particulars">Particulars<br></a>
              <a href="#Examples">Examples<br></a>

              </small>
              </td>
              <td style="vertical-align: top; width: 50%; text-align: center;">
              <small>               <a href="#Restrictions">Restrictions<br></a>
              <a href="#Literature_References">Literature_References<br></a>
              <a href="#Author_and_Institution">Author_and_Institution<br></a>
              <a href="#Version">Version<br></a>
              <a href="#Index_Entries">Index_Entries<br></a>
             </small>
            </td>
          </tr>
        </tbody>
</table>

<h4><a name="Procedure">Procedure</a></h4>
<PRE>
   void dvhat_c ( ConstSpiceDouble s1  [6],
                  SpiceDouble      sout[6] )

</PRE>
<h4><a name="Abstract">Abstract</a></h4>
<PRE>
   Find the unit vector corresponding to a state vector and the
   derivative of the unit vector.
</PRE>
<h4><a name="Required_Reading">Required_Reading</a></h4>
<PRE>
   None.
</PRE>
<h4><a name="Keywords">Keywords</a></h4>
<PRE>
   VECTOR
   DERIVATIVE
   MATH


</PRE>
<h4><a name="Brief_I/O">Brief_I/O</a></h4>
<PRE>
   VARIABLE  I/O  DESCRIPTION
   --------  ---  --------------------------------------------------
   s1        I     State to be normalized.
   sout      O     Unit vector s1 / |s1|, and its time derivative.
</PRE>
<h4><a name="Detailed_Input">Detailed_Input</a></h4>
<PRE>
   s1       This is any double precision state. If the position
            component of the state is the zero vector, this routine
            will detect it and will not attempt to divide by zero.
</PRE>
<h4><a name="Detailed_Output">Detailed_Output</a></h4>
<PRE>
   sout     sout is a state containing the unit vector pointing in
            the direction of position component of s1 and the
            derivative of the unit vector with respect to time.

            sout may overwrite s1.
</PRE>
<h4><a name="Parameters">Parameters</a></h4>
<PRE>
   None.
</PRE>
<h4><a name="Exceptions">Exceptions</a></h4>
<PRE>
   Error free.

   1) If s1 represents the zero vector, then the position
      component of sout will also be the zero vector.  The
      velocity component will be the velocity component
      of s1.
</PRE>
<h4><a name="Files">Files</a></h4>
<PRE>
   None.
</PRE>
<h4><a name="Particulars">Particulars</a></h4>
<PRE>
   Let s1 be a state vector with position and velocity components p
   and v respectively.  From these components one can compute the
   unit vector parallel to p, call it u and the derivative of u
   with respect to time, du.  This pair (u,du) is the state returned
   by this routine in sout.
</PRE>
<h4><a name="Examples">Examples</a></h4>
<PRE>
   Any numerical results shown for this example may differ between
   platforms as the results depend on the SPICE kernels used as input
   and the machine specific arithmetic implementation.
 
   Suppose that 'state' gives the apparent state of a body with
   respect to an observer.  This routine can be used to compute the
   instantaneous angular rate of the object across the sky as seen
   from the observers vantage.

      #include &quot;SpiceUsr.h&quot;
      #include &lt;stdio.h&gt;
      #include &lt;math.h&gt;

      int main()
         {

         SpiceDouble       et;
         SpiceDouble       ltime;
         SpiceDouble       omega;
         SpiceDouble       state  [6];
         SpiceDouble       ustate [6];

         SpiceChar       * epoch  = &quot;Jan 1 2009&quot;;
         SpiceChar       * target = &quot;MOON&quot;;
         SpiceChar       * frame  = &quot;J2000&quot;;
         SpiceChar       * abcorr = &quot;LT+S&quot;;
         SpiceChar       * obsrvr = &quot;EARTH BARYCENTER&quot;;

         /.
         Load SPK, PCK, and LSK kernels, use a meta kernel for convenience.
         ./
         <a href="furnsh_c.html">furnsh_c</a> ( &quot;standard.tm&quot; );

         /.
         Define an arbitrary epoch, convert the epoch to ephemeris time.
         ./
         <a href="str2et_c.html">str2et_c</a> ( epoch, &amp;et );

         /.
         Calculate the state of the moon with respect to the earth-moon
         barycenter in J2000, corrected for light time and stellar aberration
         at ET.
         ./

         <a href="spkezr_c.html">spkezr_c</a> ( target, et, frame, abcorr, obsrvr, state, &amp;ltime );

         /.
         Calculate the unit vector of STATE and the derivative of the
         unit vector.
         ./
         <b>dvhat_c</b> ( state, ustate );

         /.
         Calculate the instantaneous angular velocity from the magnitude of the
         derivative of the unit vector.

            v = r x omega

             ||omega|| = ||v||  for  r . v = 0
                         -----
                         ||r||

             ||omega|| = ||v||  for  ||r|| = 1
         ./
         omega = <a href="vnorm_c.html">vnorm_c</a>( &amp;ustate[3] );

         printf( &quot;Instantaneous angular velocity, rad/sec %.10g\n&quot;, omega );
         
         return 0;
         }

   The program outputs:
   
      Instantaneous angular velocity, rad/sec 2.48106658e-06
</PRE>
<h4><a name="Restrictions">Restrictions</a></h4>
<PRE>
   None.
</PRE>
<h4><a name="Literature_References">Literature_References</a></h4>
<PRE>
     None.
</PRE>
<h4><a name="Author_and_Institution">Author_and_Institution</a></h4>
<PRE>
     W.L. Taber      (JPL)
     E.D. Wright     (JPL)
</PRE>
<h4><a name="Version">Version</a></h4>
<PRE>
   -CSPICE Version 1.0.1, 06-MAY-2010  (EDW)

      Reordered header sections to proper NAIF convention.
      Minor edit to code comments eliminating typo.

   -CSPICE Version 1.0.0, 07-JUL-1999  (EDW)
</PRE>
<h4><a name="Index_Entries">Index_Entries</a></h4>
<PRE>
   State of a unit vector parallel to a state vector
</PRE>
<h4>Link to routine dvhat_c source file <a href='../../../src/cspice/dvhat_c.c'>dvhat_c.c</a> </h4>

      </td>
    </tr>
  </tbody>
</table>

   <pre>Wed Jun  9 13:05:21 2010</pre>

</body>
</html>

